<template>
  <md-scroll-view id="taxi-poi-list" ref="scroller" :auto-reflow="true" :scrolling-x="false" :bouncing="false">
    <md-field class="field-list" v-if="searchList.length>0">
      <search-item type="search" v-for="(item,index) in searchList" :key="index" :info="item" @select="onItemSelect(item)"></search-item>
    </md-field>
    <md-field class="field-list" v-if="searchList.length==0&&isStart">
      <search-item type="search" v-for="(item,index) in poiList" :key="index" :info="item" @select="onItemSelect(item)"></search-item>
    </md-field>
    <md-field class="field-list" v-if="searchList.length==0&&!isStart">
      <search-item type="history" v-for="(item,index) in historyList" :key="index" :info="item" @select="onItemSelect(item)"></search-item>
    </md-field>
  </md-scroll-view>
</template>

<script>
import SearchItem from './SearchItem';
import { Field, ScrollView, Popup, Icon } from 'mand-mobile';
export default {
  name: 'taxi-poi-list',
  components: {
    [SearchItem.name]: SearchItem,
    [Field.name]: Field,
    [ScrollView.name]: ScrollView,
    [Popup.name]: Popup,
    [Icon.name]: Icon
  },
  props: {
    searchList: {
      type: Array,
      default: () => {
        return [];
      }
    },
    poiList: {
      type: Array,
      default: () => {
        return [];
      }
    },
    historyList: {
      type: Array,
      default: () => {
        return [];
      }
    },
    isStart: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    onItemSelect(item) {
      this.$emit('onItemSelect', item);
    }
  }
};
</script>
